<template>
  <div class="indexPage">
    <!--    <van-nav-bar :title="pageTitle" left-arrow @click-left="handleNavLeftClick" v-if="!$isDD" class="page" />-->
    <div class="content">
      <van-tabs v-model="tabActiveName">
        <van-tab title="综合考核评分" name="score">
          <div class="tabContainer">
            <keep-alive>
              <scoreRanking></scoreRanking>
            </keep-alive>
          </div>
        </van-tab>
        <van-tab title="业务超额奖金" name="bonus">
          <no-data :desc="'驾驶舱正在逐步建设中，欢迎向项目组提出宝贵需求与建议。'"></no-data>
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>

<script>
import NoData from '@/components/NoData'
import scoreRanking from './scoreRanking.vue'
import sensormixin from '@/mixins'
export default {
  mixins: [sensormixin],
  data() {
    return {
      pageTitle: '绩效考核',
      tabActiveName: 'score'
    }
  },
  components: {
    NoData,
    scoreRanking
  },
  created() {
    if (this.$isDD) {
      this.$dd.ui.webViewBounce.disable()
      this.setTitle()
      this.$dd.ready(() => {
        if (this.$dd.android) {
          document.addEventListener('backbutton', this.backButtonEvent)
        } else {
          this.$dd.biz.navigation.setLeft({
            control: true,
            text: '',
            onSuccess: result => {
              this.$router.back()
            },
            onFail(err) {
              console.log('返回失败', err)
            }
          })
        }
      })
    }
    try {
      this.openPerformanceAPageForSensor()
    } catch (err) {
      console.log('打开综合考核评分A类页面：', err)
    }
  },
  mounted() {},
  destroyed() {
    if (this.$dd.android) {
      document.removeEventListener('backbutton', this.backButtonEvent)
    }
  },
  methods: {
    handleNavLeftClick() {
      this.$router.back()
    },
    /** 设置标题 */
    setTitle() {
      if (this.$isDD) {
        this.$dd.ready(() => {
          this.$dd.biz.navigation.setTitle({ title: '绩效考核' })
        })
      }
    },
    backButtonEvent(ev) {
      if (ev) {
        ev.preventDefault() // 阻止返回
      }
      this.$router.back()
    }
  }
}
</script>

<style lang="scss" scoped>
.indexPage {
  .page {
    padding-top: 46px;
  }
  .content {
    font-size: 14px;
    color: #fff;
    display: block;
    /deep/.van-tab__text {
      font-size: 16px;
    }
    .tabContainer {
      padding: 10px 20px 20px 20px;
    }
  }
}
</style>
